package com.im.partchat.mvp.model.group;

import com.im.partchat.bean.reponsed.BaseResponse;
import com.im.partchat.bean.reponsed.GroupQueryReponse;
import com.im.partchat.bean.request.GroupCreateRequest;
import com.im.partchat.bean.request.GroupDismissRequest;
import com.im.partchat.bean.request.GroupJoinRequest;
import com.im.partchat.bean.request.GroupQueryRequest;
import com.im.partchat.bean.request.GroupQuitRequest;
import com.im.partchat.bean.request.GroupRefreshRequest;
import com.im.partchat.bean.request.RequestBean;
import com.im.partchat.http.service.GroupService;

import java.util.List;

import io.reactivex.Observable;

/**
 * Created by flyou on 2017/6/30.
 * VersionCode: 1
 * Desc:
 */

public class GroupModelImpl implements GroupModel {
    @Override
    public Observable<BaseResponse<String>> groupCreate(String userId, String name, String ids) {

        RequestBean<GroupCreateRequest> requestBean = new RequestBean<>();
        requestBean.setData(new GroupCreateRequest(userId,name,ids));
        return GroupService.groupCreate(requestBean);
    }

    @Override
    public Observable<BaseResponse<String>> groupJoin(String groupId, String name, String ids) {
        RequestBean<GroupJoinRequest> requestBean = new RequestBean<>();
        requestBean.setData(new GroupJoinRequest(groupId,name,ids));
        return GroupService.groupJoin(requestBean);
    }

    @Override
    public Observable<BaseResponse<String>> groupQuit(String groupId, String ids) {
        RequestBean<GroupQuitRequest> requestBean = new RequestBean<>();
        requestBean.setData(new GroupQuitRequest(groupId,ids));
        return GroupService.groupQuit(requestBean);
    }

    @Override
    public Observable<BaseResponse<String>> groupDismiss(String userId, String groupId) {
        RequestBean<GroupDismissRequest> requestBean = new RequestBean<>();
        requestBean.setData(new GroupDismissRequest(userId,groupId));
        return GroupService.groupDismiss(requestBean);
    }

    @Override
    public Observable<BaseResponse<String>> groupRefresh(String groupId, String name) {
        RequestBean<GroupRefreshRequest> requestBean = new RequestBean<>();
        requestBean.setData(new GroupRefreshRequest(groupId,name));
        return GroupService.groupRefresh(requestBean);
    }

    @Override
    public Observable<BaseResponse<List<GroupQueryReponse>>> groupQuery(String groupId) {
        RequestBean<GroupQueryRequest> requestBean = new RequestBean<>();
        requestBean.setData(new GroupQueryRequest(groupId));
        return GroupService.groupQuery(requestBean);
    }
}
